package fnord.jovian.tango;

import java.awt.*;
import java.awt.geom.Rectangle2D;

public class TheTriangle implements TheObject {
	
	protected Polygon _thePolygon;
	protected double _rot;
	
	public TheTriangle() {
		_thePolygon = new Polygon(new int[] {0,3,3,9,9,12,6},new int[] {2,2,0,0,2,2,8},7);
	}
	
	public TheTriangle(double rot) {
		_thePolygon = new Polygon(new int[] {0,3,3,9,9,12,6},new int[] {2,2,0,0,2,2,8},7);
		setRotation(rot);
	}
	
	public void setLocation(double x, double y) {
		Rectangle2D box = _thePolygon.getBounds2D();
		_thePolygon.translate((int)(x - box.getX()), (int)(y - box.getY()));
	}
	
	public void setRotation(double rot) {
		_rot = rot;
	}
	
	public void paint(Graphics2D g) {
		Rectangle2D box = _thePolygon.getBounds2D();
		g.rotate(_rot,box.getCenterX(), box.getCenterY());
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g.setColor(new Color(150,150,150));
		g.fill(_thePolygon);
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
		g.rotate(-_rot,box.getCenterX(), box.getCenterY());

	}

	@Override
    public boolean contains(Point p) {
	    // TODO Auto-generated method stub
	    return false;
    }

	@Override
    public boolean containsClick(Point p) {
	    // TODO Auto-generated method stub
	    return false;
    }

	@Override
    public boolean containsDrag(Point p) {
	    // TODO Auto-generated method stub
	    return false;
    }

	@Override
    public boolean containsUp(Point p) {
	    // TODO Auto-generated method stub
	    return false;
    }


	@Override
    public double getX() {
	    return _thePolygon.getBounds2D().getX();
    }

	@Override
    public double getY() {
	    return _thePolygon.getBounds2D().getY();
    }

	@Override
    public double getCenterX() {
	    return _thePolygon.getBounds2D().getCenterX();
    }

	@Override
    public double getCenterY() {
	    return _thePolygon.getBounds2D().getCenterY();
    }

	@Override
    public double getWidth() {
	    return _thePolygon.getBounds2D().getWidth();
    }

	@Override
    public double getHeight() {
	    return _thePolygon.getBounds2D().getHeight();
    }

	@Override
    public void setSize(double w, double h) {
	    // TODO Auto-generated method stub
	    
    }
}
